# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-wubi
pkgver=0.0.0.20200908
_commit=f1876f08f1d4a9696395be0070c0e8e4353c44cb
pkgrel=1
pkgdesc="Wubi input for rime"
arch=('loong64' 'x86_64')
url="https://github.com/rime/rime-wubi"
license=('LGPL')
# dependency for reverse lookup
depends=('rime-pinyin-simp')
makedepends=('librime' 'rime-prelude' 'rime-essay')
source=("https://github.com/rime/rime-wubi/archive/$_commit/rime-wubi-$_commit.tar.gz")
sha512sums=('bc7dac4c11f062640c61556078d0847b5033a105a5f8b15a26a487e16cb323e9b4cf38d34c33f453b85537ee8314adf1a20e136422c12598b7af63d2c9533d7e')

prepare() {
  cd $pkgname-$_commit
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname-$_commit
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname-$_commit
  find . -type l -delete
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
